/**
 * 
 */
package smallChanges.statements;

import smallChanges.Tokenization.TokenSet;
import smallChanges.util.HashCodeUtil;

/**
 * @author jspacco
 *
 */
public class SCType extends MultiTokenCodeRange2D
{
	private String type;
	private boolean arrayType;
	// primitive or reference?
	private String kind;
	
	
	public SCType(TokenSet tokenSet) {
	    super(tokenSet);
	    //this.tokenSet=tokenSet;
	    //range=new MultiTokenCodeRange2D(this.tokenSet);
	}
	
	public boolean equals(Object otherObj)
	{
		boolean retVal = true;
		if(this == otherObj)
		{
			return true;
		}
		if((otherObj == null) || (otherObj.getClass() != this.getClass()))
		{
			return false;
		}
	
		SCType other = (SCType) otherObj;
		if( (type == null || other.type == null) && (type != other.type) )
		{
			retVal = false;
		}

		if( type != null && other.type != null && !type.equals(other.type))
		{
			retVal = false;
		}
		
		if( arrayType != other.arrayType)
		{
			retVal = false;
		}
		
		if( (kind == null || other.kind == null) && (kind != other.kind) )
		{
			retVal = false;
		}

		if( kind != null && other.kind != null && !kind.equals(other.kind))
		{
			retVal = false;
		}
		return retVal;
	}
	
//	public SCType(String type, boolean isArray, String kind) {
//		setType(type);
//		setArrayType(isArray);
//		setKind(kind);
//	}
	
//	public String toString() {
//		return range.getTokenImage();
////	    if (isArrayType()) {
////			return type+"[]";
////		}
////		return type;
//	}
	
	/**
	 * @return the type
	 */
	public String getType()
	{
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(String type)
	{
		this.type = type;
	}
	/**
	 * @return the isArray
	 */
	public boolean isArrayType()
	{
		return arrayType;
	}
	/**
	 * @param isArray the isArray to set
	 */
	public void setArrayType(boolean isArray)
	{
		this.arrayType = isArray;
	}
	/**
	 * @return the kind
	 */
	public String getKind()
	{
		return kind;
	}
	/**
	 * @param kind the kind to set
	 */
	public void setKind(String kind)
	{
		this.kind = kind;
	}

	public int hashCode() {
		int retVal = 0;
		retVal = HashCodeUtil.hash(retVal, type);
		retVal = HashCodeUtil.hash(retVal, kind);
		retVal = HashCodeUtil.hash(retVal, arrayType);

		return retVal;
	}

//    public MultiTokenCodeRange2D getRange()
//    {
//        return range;
//    }
//
//    public void setRange(MultiTokenCodeRange2D range)
//    {
//        this.range = range;
//    }

}
